package com.smxy.hunzi.article.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.smxy.hunzi.article.entity.LabelEntity;
import com.smxy.hunzi.article.service.LabelService;
import com.smxy.hunzi.common.utils.PageUtils;
import com.smxy.hunzi.common.utils.R;



/**
 * 标签表
 *
 * @author litao
 * @email 4028546@qq.com
 * @date 2020-08-14 12:32:46
 */
@RestController
@RequestMapping("article/label")
public class LabelController {
    @Autowired
    private LabelService labelService;

    /**
     * 列表
     */
    @RequestMapping("/list")
   // @RequiresPermissions("article:label:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = labelService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
   // @RequiresPermissions("article:label:info")
    public R info(@PathVariable("id") Long id){
		LabelEntity label = labelService.getById(id);

        return R.ok().put("label", label);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
   // @RequiresPermissions("article:label:save")
    public R save(@RequestBody LabelEntity label){
		labelService.save(label);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
  //  @RequiresPermissions("article:label:update")
    public R update(@RequestBody LabelEntity label){
		labelService.updateById(label);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("article:label:delete")
    public R delete(@RequestBody Long[] ids){
		labelService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
